<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>聊天工具网页版</title>
	<script src="js/jquery-1.11.0.min.js"></script>
<style type="text/css">

	
.chart1{
	width: 500px;
	height: 220px;
	border-color: #66CDAA;
	border-style: 2px;
	margin:auto;
	margin-top: 200px;
	border:solid 2px;
	
	
}
.chart2{
	width: 500px;
	height: 40px;
	line-height: 30px;
	
	background-color: #3CB371;
	text-align: center;
	font-weight: bold;
	font-size: 22px;
	
}
.chart3{
	font-size: 18px;
	font-weight: bold;
	margin: auto;
	text-align: center;
}
	


.style{
	width:200px;
	height:30px;
	background-color:#FFFFFF;
	border-style:hidden;
	border-radius:5px;
	border:1px solid #ccc;
	padding-left: 5px;
}
.style1{
	width: 100px;
	height: 30px;
	background-color: #FFFFFF;
	border-style: hidden;
	border-radius:5px;
	border:1px solid #ccc;
	
}

</style>
<head>
<body>
	
<hr color="grey"  >
<div  class="chart1" >
	<div class="chart2" >登&nbsp;录</div><br>
	<div class="chart3">	
	用户名：<input type="text"  class="style" id="username"><br><br>
	密&nbsp;&nbsp;&nbsp;码： <input type="password"  class="style" id="password">
	<br><br>
		
	<input type="reset"  value="重置"  class="style1" id="reset">
	<input type="submit" value="登录" class="style1" id="submit">

	</div>
	</div>
	
</body>	
	<script>
	$(document).ready(function() {
		$("#submit").click(submit);
		$(document).keydown(function(){
			if (event.keyCode === 13) {
				submit();
			};
		});
		$("#reset").click(function() {
			$("#username").val("");
			$("#password").val("");
		})
	});
	function submit () {
		var username = $("#username").val();
		var password = $("#password").val();
		$.ajax({
			url: 'php/interface.php?action=login',
			method: 'post',
			dataType: 'json',
			data: {
				username: username,
				password: password
			}
		}).done(function(data) {
			if (data.result === true) {
				location.href = 'index.html';
			} else {
				alert(data.msg);
			}
		});
	}
	</script>
</html>
